<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="SuperTablePage" :autoLoad="true" >
      <template v-slot:table_footer>
          <el-table-column
            v-if="tableHeaders && tableHeaders.length > 0"
            v-for="item,index in tableHeaders"
            :key="'col_' + index"
            :label="item.label"
            :prop="item.value"
            min-width="100"
            align="center"
          >
            <!--   :fixed="index >= tableHeaders.length-3 ? 'right' : false "  -->
          </el-table-column>

      </template>
    </ex_super_table_page>

    <ex-export-form ref="exExportForm"></ex-export-form>

  </div>
</template>

<script>
import business_function from "@/common/business_function"
import superTablePageFunction from "@/mixin/super-table-page-function";

export default {
  name: "label_rent_statis",
  title: 'label_rent_statis',
  mixins: [  superTablePageFunction,],

  components: {},
  data() {
    return {
      option: {
        //搜索框内容
        search: {
          //搜索框内容，key为搜索字段，label为标签提示
          model: [
            {
              label: "label_putaway_time",
              key: "putawayTimeStart",
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
            {
              label: "-",
              key: "putawayTimeEnd",
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
          ],
        },
        actionExtra: [
          {
            label: 'label_export', click:()=>{
              const params = this.$refs.SuperTablePage.getSearchFormData()
              this.$refs['exExportForm'].doExport('/wms-api/stock/WmsStockHistoryRpc/exportHistoryRent.json', params)
            }
          },
        ],
        table: {
          url: "/wms-api/stock/WmsStockHistoryRpc/historyRentQuery.json",
          urlParams: {
            // reprotType: 'WAREHOUSE_TAKE_DOWN'
          },
          urlDataHandle: this.dataHandle,
          autoPage: false,
          emptySlot: false,
          model: [
          ],
        }

      },

      tableHeaders: []

    }
  },
  methods: {

    formatter(r, c, v, i){

    },

    dataHandle(res) {
      // console.log('dataHandle:' + JSON.stringify(res))
      // this.tableColumns = []

      if(res && res.data && res.data.heads ){
        this.tableHeaders = res.data.heads
      }

      console.log(this.tableHeaders)


      res.data.rows.forEach(r=>{
        r.time = this.$dateFormat(r.time)
      })

      return res.data.rows;
    },


    exportExcel() {
      const searchParams = this.$refs.SuperTablePage.getSearchData()
      business_function.confirmOperateBaseSelectOrForm.call(this, {
        data: searchParams,
        model: this.option.search.model,
        callback: (selection, data) => {
          let params = data
          this.$functionCommon({
            url: "/wms-api/stock/StockQueryRpc/stockContainerExportExcel.json",
            data: params, type: 'form', 
          })
        }
      })

    },
  }

}
</script>

<style scoped></style>
